#include "s3e.h"
#include "Iw2D.h"
#include "Box2D/Box2D.h"
#include "IwGx.h"
#include "IwUI.h"
#include "Game.h"


// updates per second
#define UPS 60

// throttle frame time at 10 fps (i.e. the game will slow down rather
// than having very low frame rate)
#define MAX_UPDATES 6

int GetUpdateFrame()
{
    return (int)(s3eTimerGetMs() / (1000/UPS));
}


#define MS_PER_FRAME (1000 / 25)



// "main" is the S3E entry point
int main()
{
	Game* pGame = new Game;
	pGame->Init();

	while (!s3eDeviceCheckQuitRequest())
	{
		// Clear the screen
		IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
		
		//Set screen color
		IwGxSetColClear(0xff, 0xff, 0xff, 0xff);

		pGame->Update();
		pGame->Render();


		// Show
		IwGxFlush();
		IwGxSwapBuffers();

		// Device interaction
		s3eDeviceYield();
		s3eKeyboardUpdate();
		s3ePointerUpdate();

	}
	pGame->Shutdown();

	return 0;
}
